package com.shiroha.common.event;

import com.fasterxml.jackson.annotation.JsonValue;
import com.mybatisflex.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum ServiceEventType {
    USER_CREATED(0, "创建用户"),
    USER_UPDATED(1, "更新用户"),
    FOLLOW(2, "关注"),
    WORK_PUBLISH(3, "作品发布"),
    WORK_LIKE(4, "作品点赞"),
    WORK_COMMENT(5, "作品评论"),
    WORK_FAVORITE(6, "作品收藏"),
    COMMENT_LIKE(7, "评论点赞"),
    COMMENT_REPLY(8, "评论回复"),
    ;

    @EnumValue
    @JsonValue
    private final int value;
    private final String description;

    ServiceEventType(int value, String description) {
        this.value = value;
        this.description = description;
    }

    public static ServiceEventType fromValue(int value) {
        for (ServiceEventType type : ServiceEventType.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("未找到对应的枚举值: " + value);
    }
}
